<?php
class Laporan_model extends Model{
	function laporan_model(){
		parent::Model();
	}
	
	//data keseluruhan
	function get_1bln(){
		$hasil = $this->db->query('SELECT periode_1bln.Periode, periode_1bln.HASIL, periode_1bln.WAKTU, cabang.cabang as cabang, bobot.nama_bobot as bobot FROM periode_1bln, cabang, bobot WHERE periode_1bln.ID_CABANG = cabang.id_cabang AND periode_1bln.ID_BOBOT = bobot.id_bobot');
		return $hasil->result();	
	}
	
	//ambil tabel by id
	function get_1bln_by_id($id_cabang){
		$hasil = $this->db->query('SELECT periode_1bln.Periode, periode_1bln.HASIL, periode_1bln.WAKTU, cabang.cabang as cabang, bobot.nama_bobot as bobot FROM periode_1bln, cabang, bobot WHERE periode_1bln.ID_CABANG = cabang.id_cabang AND periode_1bln.ID_BOBOT = bobot.id_bobot AND cabang.id_cabang ='.$id_cabang);
		return $hasil->result();	
	}
	
	//data keseluruhan
	function get_3bln(){
		$hasil = $this->db->query('SELECT periode_3bln.Periode, periode_3bln.HASIL, periode_3bln.WAKTU, cabang.cabang as cabang, bobot.nama_bobot as bobot FROM periode_3bln, cabang, bobot WHERE periode_3bln.ID_CABANG = cabang.id_cabang AND periode_3bln.ID_BOBOT = bobot.id_bobot');
		return $hasil->result();
	}
	
	//ambil tabel by id
	function get_3bln_by_id($id_cabang){
		$hasil = $this->db->query('SELECT periode_3bln.Periode, periode_3bln.HASIL, periode_3bln.WAKTU, cabang.cabang as cabang, bobot.nama_bobot as bobot FROM periode_3bln, cabang, bobot WHERE periode_3bln.ID_CABANG = cabang.id_cabang AND periode_3bln.ID_BOBOT = bobot.id_bobot AND cabang.id_cabang ='.$id_cabang);
		return $hasil->result();
	}
	
	//ambil keseluruhan
	function get_6bln(){
		$hasil = $this->db->query('SELECT periode_6bln.Periode, periode_6bln.HASIL, periode_6bln.WAKTU, cabang.cabang as cabang, bobot.nama_bobot as bobot FROM periode_6bln, cabang, bobot WHERE periode_6bln.ID_CABANG = cabang.id_cabang AND periode_6bln.ID_BOBOT = bobot.id_bobot');
		return $hasil->result();
	}
	
	//ambil tabel by id
	function get_6bln_by_id($id_cabang){
		$hasil = $this->db->query('SELECT periode_6bln.Periode, periode_6bln.HASIL, periode_6bln.WAKTU, cabang.cabang as cabang, bobot.nama_bobot as bobot FROM periode_6bln, cabang, bobot WHERE periode_6bln.ID_CABANG = cabang.id_cabang AND periode_6bln.ID_BOBOT = bobot.id_bobot AND cabang.id_cabang ='.$id_cabang);
		return $hasil->result();
	}
	
	//ambil keseluruhan
	function get_12bln(){
		$hasil = $this->db->query('SELECT periode_12bln.Periode, periode_12bln.HASIL, periode_12bln.WAKTU, cabang.cabang as cabang, bobot.nama_bobot as bobot FROM periode_12bln, cabang, bobot WHERE periode_12bln.ID_CABANG = cabang.id_cabang AND periode_12bln.ID_BOBOT = bobot.id_bobot');
		return $hasil->result();
	}
	
	//ambil data by id
	function get_12bln_by_id($id_cabang){
		$hasil = $this->db->query('SELECT periode_12bln.Periode, periode_12bln.HASIL, periode_12bln.WAKTU, cabang.cabang as cabang, bobot.nama_bobot as bobot FROM periode_12bln, cabang, bobot WHERE periode_12bln.ID_CABANG = cabang.id_cabang AND periode_12bln.ID_BOBOT = bobot.id_bobot AND cabang.id_cabang ='.$id_cabang);
		return $hasil->result();
	}
	
	function count_table_1bln(){
		return $this->db->count_all('periode_1bln');
	}
	
	function count_table_3bln(){
		return $this->db->count_all('periode_3bln');
	}
	
	function count_table_6bln(){
		return $this->db->count_all('periode_6bln');
	}
	
	function count_table_12bln(){
		return $this->db->count_all('periode_12bln');
	}
}
?>